package com.qianbao.service.bindcard.impl;

import com.qianbao.components.excepion.CommonException;
import com.qianbao.components.excepion.ExceptionEnum;
import com.qianbao.components.uuid.SVUuidTool;
import com.qianbao.dao.bindcard.BindCardDao;
import com.qianbao.domain.bindcard.BankCardEntity;
import com.qianbao.service.bindcard.BindCardService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class BindCardServiceImpl implements BindCardService {

    @Autowired
    private BindCardDao dao;

    @Override
    public List<BankCardEntity> findAllBankCard(String customId) throws CommonException {

        if (customId != null && customId.length() > 0){
            return dao.findAllBankCard(customId);
        }else {
            throw new CommonException(ExceptionEnum.Request_Params_Invalid.getCode(),
                    ExceptionEnum.Request_Params_Invalid.getMessage());
        }
    }

    @Override
    public void insertCardInfomation(BankCardEntity entity) throws CommonException{
        // 生成唯一标识
        entity.setCard_id(SVUuidTool.getUUID());

        int rows = dao.insertCardInfomation(entity);

        if (rows > 0){

        }else {
            throw new CommonException(ExceptionEnum.Sql_insert_fail.getCode(),
                    ExceptionEnum.Sql_insert_fail.getMessage());
        }
    }


}
